﻿using Player;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PlayerIdle : PlayerBehavior,IStateBase
{

    //Animator animator;

    public PlayerIdle(PlayerBody player) : base(player)
    {
        //if (animator == null)
        //    animator = Player.GetComponent<Animator>();
    }


    public void GetState()
    {
        throw new System.NotImplementedException();
    }

    public void Interrupt()
    {
        throw new System.NotImplementedException();
    }

    public void OnEnter()
    {
        //Debug.Log("IM IDLE ENTER");
        //throw new System.NotImplementedException();
    }

    public void OnExit()
    {
        //throw new System.NotImplementedException();
    }

    public void OnFixedUpdate()
    {
        //throw new System.NotImplementedException();
    }

    public void OnUpdate(params object[] obj)
    {
        var mousePos = Camera.main.ScreenToWorldPoint(Input.mousePosition);
        float angle = Mathf.Atan2(mousePos.y - Player.transform.position.y, mousePos.x - Player.transform.position.x) * 180 / Mathf.PI;
        if (angle < 0)
        {
            angle += 360;
        }
        float flip = angle > 90 && angle <= 270 ? 0 : 180;
        Player.transform.eulerAngles = new Vector3(Player.transform.eulerAngles.x, flip, Player.transform.eulerAngles.z);

    }
}
